import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { CopySkillInfo } from "../../../resource/info/CopySkillInfo";
import { ItemData } from "../../../resource/info/ItemData";
import { SkillConfig } from "../../../resource/SkillConfig";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class SkillCombinationRenderer
    
    export  class SkillCombinationRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this._itemAry = [];
            return;
        }

        protected /* override */ configUI(): void
        {
            var loc4=null;
            var loc5=null;
            super.configUI();
            var loc1=ObjCreate.createBitmap(ImagesConst.PropBg, 0, 30, this);
            var loc2=ObjCreate.createBg(30, 106, 248, 2, this, ImagesConst.SplitLine);
            this._addBmp1 = ObjCreate.createBitmap(null, 120, 72, this);
            this._addBmp2 = ObjCreate.createBitmap(null, 200, 72, this);
            LoaderHelp.addResCallBack(ResFileConst.crossSecretCopy90, this.onResLoaded);
            var loc3=GlobalStyle.textFormat6;
            loc3.size = 14;
            loc3.bold = true;
            this._nameTxt = ObjCreate.createGTextField("", 0, 5, 200, 30, this, loc3);
            this._skillItem = new BaseItem();
            this._skillItem.setSize(58, 58);
            this._skillItem.move(6, 36);
            addChild(this._skillItem);
            this._skillItem.isDragAble = false;
            this._skillDesc = ObjCreate.createGTextField("", 72, 30, 230, 40, this);
            this._skillDesc.multiline = true;
            this._skillDesc.wordWrap = true;
            var loc6=72;
            var loc7=63;
            var loc8=0;
            while (loc8 < 3) 
            {
                loc4 = ObjCreate.createBitmap(ImagesConst.PackItemBg, loc6, loc7, this);
                (loc5 = new BaseItem()).setSize(33, 33);
                loc5.move(loc6 + 2, loc7 + 2);
                loc6 = loc6 + 80;
                this._itemAry.push(loc5);
                addChild(loc5);
                loc5.isDragAble = false;
                ++loc8;
            }
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._addBmp1.bitmapData = GlobalClass.getBitmapData(ImagesConst.crossSecretCopy90Add);
            this._addBmp2.bitmapData = GlobalClass.getBitmapData(ImagesConst.crossSecretCopy90Add);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            super.data = arg1;
            if (arg1 && arg1 is CopySkillInfo) 
            {
                this._skillInfo = arg1 as CopySkillInfo;
                this._nameTxt.text = this._skillInfo.name;
                loc1 = new ItemData(this._skillInfo.itemCode);
                loc2 = SkillConfig.instance.getInfoByName(loc1.effect);
                this._skillItem.itemData = loc1;
                this._skillDesc.htmlText = loc2.skillDescription;
                loc3 = this.getItemCodes(this._skillInfo);
                loc5 = 0;
                while (loc5 < this._itemAry.length) 
                {
                    if ((loc4 = this._itemAry[loc5] as BaseItem) && !(loc3[loc5] == 0)) 
                    {
                        loc4.itemData = new ItemData(loc3[loc5]);
                    }
                    ++loc5;
                }
            }
            return;
        }

        /* internal  */getItemCodes(arg1: CopySkillInfo): Array<any>
        {
            var loc3=null;
            var loc5=0;
            var loc1=[];
            var loc2=arg1.formula;
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc3 = loc2[loc4];
                loc5 = 0;
                while (loc5 < loc3.amountNeed) 
                {
                    loc1.push(parseInt(loc3.itemCode));
                    ++loc5;
                }
                ++loc4;
            }
            return loc1;
        }

        /* internal */ /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_skillItem: BaseItem;

        /* internal */ /* var */_skillDesc: GTextFiled;

        /* internal */ /* var */_addBmp1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_addBmp2: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_itemAry: Array<any>;

        /* internal */ /* var */_skillInfo: CopySkillInfo;
    }
